//牛客 KY222 打印日期

#include <stdio.h>

int isLeapYear(int year)
{
    if((year%4 == 0 && year%100 != 0) || (year%400 == 0))
        return 1;
    
    return 0;
}
int main() {
    int MonthDay[2][12] = {{ 31,28,31,30,31,30,31,31,30,31,30,31 },
                           { 31,29,31,30,31,30,31,31,30,31,30,31 }};
    int _year = 0, _month = 0, _day = 0;
    while(~scanf("%d %d", &_year, &_day))
    {
        int i = 0;
        while(i < 12)
        {
            if(_day <= MonthDay[isLeapYear(_year)][i])
                break;
            else
                _day -= MonthDay[isLeapYear(_year)][i];

            i++;
        }
        _month = i + 1;
        printf("%04d-%02d-%02d\n", _year, _month, _day);
    }

    return 0;
}